package com.atung.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atung.response.ResponseBusOrderCarList;
import com.atung.service.BusOrderCarService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuyi.full.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/car/order")
@Api(tags="订单模块")
public class BusOrderController {

	@Autowired
	private BusOrderCarService busOrderCarService;
	
	@ApiOperation("订单列表")
	@GetMapping("getOrderList")
	public Result getCarOrderList(@RequestParam("openId")String openId,
			@RequestParam(required=false) Integer orderState,
			@RequestParam(required=false,defaultValue="1")Integer pageNum,
			@RequestParam(required=false,defaultValue="10")Integer pageSize){
		
		PageHelper.startPage(pageNum, pageSize);
		
		List<ResponseBusOrderCarList> ResponseBusOrderCarList=busOrderCarService.getOrderList(openId, orderState);
		PageInfo<ResponseBusOrderCarList>piHelper=new PageInfo<>(ResponseBusOrderCarList);
		
		return Result.success(piHelper);
		
	}
	
	@GetMapping("/orderDetails")
	@ApiOperation("订单详情")
	public Result orderDetails(@RequestParam Long orderId){
		
		return Result.success(busOrderCarService.getOrderDetails(orderId));
	}
	
	
	@PostMapping("/riding")
	@ApiOperation("用户上车")
	public Result riding(@RequestBody Map<String,Long> mapParam){
		
		System.err.print(mapParam.get("orderId"));
		return Result.success();
	}
	
}
